/*
 * GroupActionsController.java
 *
 * Created on October 29, 2008, 12:29 AM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package org.vacuela.publishmx.web.controllers;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.vacuela.publishmx.context.ServiceContext;
import org.vacuela.publishmx.services.ContactBookService;
import org.vacuela.publishmx.util.PublishUtil;

/**
 *
 * @author nestor.carrasco
 */
public class GroupActionsController extends PublishBasedController{
    
    ContactBookService bookSvc;
    
    public void setContactBookService( ContactBookService bookService){
        bookSvc = bookService;
    }
    
    public ModelAndView commandAction(HttpServletRequest request, HttpServletResponse response, ServiceContext context) throws Exception {
        String groupId = PublishUtil.checkNull(request.getParameter("groupAction"),"");
        if ( !"".equals(groupId)){
            context.setAttribute("groupId",new Integer(groupId));
            this.bookSvc.deleteGroup(context);
        }
        return new ModelAndView("home");
    }
}
